<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2020/8/20
  Time: 16:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="/css/query.css">
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    String eid=request.getParameter("eid");
    String ename=request.getParameter("eName");
    String edate=request.getParameter("edate");
    String espt=request.getParameter("espt");
    String price=request.getParameter("price");

    int num = request.getIntHeader("num");



%>
<%!
    public static final String DBDriver="com.mysql.jdbc.Driver";
    public static final String DBUrl="jdbc:mysql://localhost:3306/invoicing_system";
    public static final String DBUserName="root";
    public static final String DBPwd="root";
%>

<%
    Connection conn=null;
    PreparedStatement ps=null;
    ResultSet rs=null;
    Class.forName(DBDriver);
    String suppName=(String)request.getSession().getAttribute("SloginedName");
    conn= DriverManager.getConnection(DBUrl,DBUserName,DBPwd);
    String sql="insert into equipment(eid,e_name,p_date,spt,price) values(?,?,?,?,?)";
    ps=conn.prepareStatement(sql);
    ps.setString(1,eid);
    ps.setString(2,ename);
    ps.setString(3,edate);
    ps.setString(4,espt);
    ps.setString(5,price);
    int i=ps.executeUpdate();
%>
<%
    String sql1="insert into production(sid,eid,num) values('"+suppName+"',?,?)";
    ps=conn.prepareStatement(sql1);
    ps.setString(1,eid);
    ps.setInt(2,num);
    int j =ps.executeUpdate();
%>
<%
    ps.close();
    conn.close();
    response.sendRedirect("suppequip.jsp");
%>
<div class="submit" align="center">
    <form action="mysqlinsert.jsp" method="post">
        <table class="table2">
            <tr style="height: 60px">
                <td width="150px" align="right">设备号：</td>
                <td><input class="put" type="text" name="eid"></td>
            </tr>
            <tr style="height: 60px">
                <td align="right">设备名：</td>
                <td><input class="put" type="text" name="eName"></td>
            </tr>
            <tr style="height: 60px">
                <td align="right">生产日期：</td>
                <td><input class="put" type="date" name="edate"></td>
            </tr>
            <tr style="height: 60px">
                <td align="right">规格大小：</td>
                <td><input class="put" type="text" name="espt"></td>
            </tr>
            <tr style="height: 60px">
                <td align="right">价格：</td>
                <td><input class="put" type="text" name="price"></td>
            </tr>
            <tr style="height: 60px">
                <td align="right">库存：</td>
                <td><input class="put" type="number" name="num"></td>
            </tr>
            <tr height = "60px;" align = "center">
                <td colspan = "2"><input class = "sub" type="submit" value="提交 "></td>
            </tr>
        </table>
    </form>

</div>
</body>
</html>
